<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/displaytag.tld" prefix="display"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ page contentType="text/html;charset=utf-8"
	import="com.cs.beneficios.common.ConnectionFactory,com.cs.paoyer.administration.business.model.UserVO,com.cs.beneficios.common.entity.Consultas,java.sql.Connection,java.sql.ResultSet,java.sql.SQLException,com.cs.beneficios.common.entity.database"%>

<%
	UserVO user = (UserVO) session.getAttribute("userInfo");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Consultar Programa</title>
<script type="text/javascript"
	src="<%=request.getContextPath() + "/js/popUPdesc.js"%>"></script>
<link href="<%=request.getContextPath() + "/css/bloques.css"%>"
	rel="stylesheet" type="text/css">
<script type="text/javascript">
    function activarvalor(locacion1)
    {
      document.form.action=locacion1;
      document.form.submit();
    }
    
    function flimpiar()
    {
      document.form.Programa.value = "";
    }
    
    function flimpiar1()
    {
      document.form.secretaria.value = "";
    }

    
   </script>

</head>
<body>
	<%
		request.setCharacterEncoding("utf-8");
	%>

	<DIV align="center">
		<table
			style="width: 80%; border: 0; padding: 1px; border-spacing: 2px;">
			<tr>
				<td align="center" class="titulosenblanco">ADMINISTRACI&Oacute;N&nbsp;DE
					PROGRAMAS</td>
			</tr>
		</table>
	</DIV>
	<P align="center">
	<table style="width: 60%; border: 0; padding: 0; border-spacing: 0;">
		<tr>
			<td>
				<div align="right">
					<table
						style="width: 30%; border: 0; padding: 0; border-spacing: 0;">
						<tr />
						<tr>
							<td align="right"><html:link
									page="/programas/IngresarPrograma.do">
									<img
										src="<%=request.getContextPath() + "/images/b_nuevo.gif"%>"
										alt="Nuevo" width="22" height="22" border="0" />
									<br />
								</html:link> <strong>Nuevo Programa</strong></td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td align="center" width="40%">
								<%
									String Ruta2 = "'" + request.getContextPath()
											+ "/programas/ActivarProgramas.do'";
								%> <input type="image" onclick="activarvalor(<%=Ruta2%>)"
								src="<%=request.getContextPath() + "/images/activar.gif"%>" />
								<strong>Activar Programas</strong>
							</td>

						</tr>
					</table>
				</div>
			</td>
		</tr>
	</table>

	<DIV align="center">
		<form name="form" method="post"
			action="<%=request.getContextPath()
					+ "/programas/ConsultarPrograma.do"%>">
			<input type="hidden" name="Codigo">
			<div align="center">
				<table
					style="width: 100; border: 0; padding: 3px; border-spacing: 3px;">
					<tr>
						<td width="2%" colspan="3">
							<P align="center" class="celdatabla">Seleccione un criterio
								para consultar programas</P>
						</td>
					</tr>
					<tr>
						<td width="2%">&nbsp;</td>
						<td width="17%" class="celdatabla">
							<P>
								<STRONG>Programa</STRONG>
							</P>
						</td>
						<td><input type="text" class="form" name="Programa" value=""
							onchange="flimpiar1()" maxlength="50" size="50" /></td>
					</tr>

					<%
						//ConnectionFactory cf = new ConnectionFactory("beneficios","beneficios");
						ConnectionFactory cf = new ConnectionFactory();
						Consultas consulta = new Consultas(cf);
						Connection conn = cf.getConnection();
						database db = new database();
						ResultSet rs = null;
						String strsecretaria = request.getParameter("secretaria");
						rs = consulta.getNomSecretaria();

						if (rs != null) {
					%>
					<tr>
						<td width="2%">&nbsp;</td>
						<td width="17%" class="celdatabla"><STRONG>Secretaria</STRONG>
						</td>
						<td width="79%"><select name="secretaria" class="formLista"
							onchange="flimpiar()">
								<option value="" class="form">SELECCIONE LA SECRETARIA</option>
								<%
									try {
											while (rs.next()) {
												if (strsecretaria != null) {
													if (strsecretaria.equals(rs.getString("codigo"))) {
								%>
								<option class="formLista" selected="selected"
									value="<%=rs.getString("codigo")%>"><%=rs.getString("nombre")%></option>
								<%
									} else {
								%>
								<option class="formLista" value="<%=rs.getString("codigo")%>"><%=rs.getString("nombre")%></option>
								<%
									}
												} else {
								%>
								<option class="formLista" value="<%=rs.getString("codigo")%>"><%=rs.getString("nombre")%></option>
								<%
									}
											}
								%>
						</select> <%
 	} catch (SQLException e) {
 		}
 		cf.closeConnection(conn);
 %></td>
					</tr>
					<%
						} else {
					%>
					<tr>
						<td colspan="3">Ocurrio un error</td>
					</tr>
					<%
						}
					%>
					<tr>
						<td colspan="4">&nbsp;</td>
					</tr>
					<tr>
						<td colspan="4">
							<DIV align="center">
								<input type="submit" value="Consultar" />
							</DIV>
						</td>
					</tr>
				</table>
			</div>
			<P>
				<%
					if (session.getAttribute("mensajes") != null) {
						out.println((String) session.getAttribute("mensajes"));
					}
					session.removeAttribute("mensajes");
				%>
			</P>

			<div align="center">
				<table class="tablaGenericaWidth90">

					<tr>
						<td><logic:notPresent scope="request" name="programas">
								<DIV align="center"><%=request.getAttribute("msg")%></DIV>
							</logic:notPresent> <logic:present scope="request" name="programas">
								<display:table name="requestScope.programas"
									requestURI='<%=request.getContextPath()
							+ "/programas/ConsultarPrograma.do"%>'
									class="bordesTable" pagesize="20" id="pro" cellpadding="3"
									cellspacing="1" style="width:100%">
									<display:column headerClass="headerTable" title="Programa"
										class="Numero" sortable="false">
										<html:link paramId="Codigo" paramName="pro"
											paramProperty="code" page="/programas/ModificarPrograma.do">
											<bean:write name="pro" property="nombre" />
										</html:link>
									</display:column>
									<display:column headerClass="headerTable" title="Area"
										class="Numero" sortable="false">
										<bean:write name="pro" property="nombreArea" />
									</display:column>
									<display:column headerClass="headerTable" title="Modificar"
										class="Numero">
										<html:link paramId="Codigo" paramName="pro"
											paramProperty="code" page="/programas/ModificarPrograma.do">
											<div align="center">
												<img
													src="<%=request.getContextPath()
									+ "/images/modificar.gif"%>"
													width="16" height="16" border="0">
											</div>
										</html:link>
									</display:column>
									<bean:define id="Codigo" name="pro" property="code"></bean:define>
									<bean:define id="codsecret" name="pro" property="codeArea"></bean:define>
									<%
										java.util.HashMap params = new java.util.HashMap();
												params.put("codePrograma", Codigo);
												params.put("ori", "consulprog");
												params.put("codsecret", codsecret);
												//params.put("codePrograma", Codigo);
												pageContext.setAttribute("parametros", params);
									%>
									<display:column headerClass="headerTable"
										title="Nuevo Beneficio" class="Numero">
										<html:link name="parametros" scope="page"
											page="/subprogramas/IngresarSubprograma.do">
											<div align="center">
												<img
													src="<%=request.getContextPath()
									+ "/images/nuevo.gif"%>"
													width="16" height="16" border="0">
											</div>
										</html:link>
									</display:column>
									<display:column headerClass="headerTable" title="Desactivar"
										class="Numero">
										<bean:define id="Programa" name="pro" property="code"></bean:define>
										<div align="center">
											<a
												onclick="return confirm('¿Está seguro que desea desactivar el Programa?')"
												href='javascript:vpopUsers("<%=request.getContextPath()
								+ "/jsp/programas/RazonDesactivar.jsp"%>?Programa=<%=Programa%>");'>
												<img
												src="<%=request.getContextPath()
								+ "/images/Delete.gif"%>"
												width="16" height="16" border="0">
											</a>
										</div>
									</display:column>
								</display:table>
							</logic:present></td>
					</tr>

				</table>
			</div>
		</form>
	</DIV>
	<%
		cf.closeConnection(consulta.getConn());
	%>
</body>
</html>
